package com.zretc.notice.service;


import com.zretc.notice.Dao.ActParticipantsDao;
import com.zretc.notice.pojo.ActivityParticipants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 功能：
 * 作者：111
 * 日期：2024/7/4 22:42
 */
@Service
public class ActParticipantsService {

    @Autowired
    ActParticipantsDao actParticipantsDao;

    //用户报名活动
    public ActivityParticipants enroll(Integer activityId, Integer userId){
        ActivityParticipants activityParticipants =new ActivityParticipants();
        activityParticipants.setActivityId(activityId);
        activityParticipants.setUserId(userId);
        actParticipantsDao.save(activityParticipants);
        //System.out.println("here");
        return activityParticipants;
    }




    //获取用户活动记录
    public List<Integer> selectActivity(Integer userId){
        List<Integer> actIdList = new ArrayList<>();
        for(ActivityParticipants activityParticipants:actParticipantsDao.findAllByUserId(userId)){
            actIdList.add(activityParticipants.getActivityId());
        }
        return actIdList;
    }
}